package com.vic.controller;

import com.vic.entity.GoodsInfo;
import com.vic.entity.query.GoodsInfoQuery;
import com.vic.entity.vo.ResponseVO;
import com.vic.controller.global.BaseController;
import com.vic.service.GoodsInfoService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
 * @description：商品信息Controller
 * @date：2023-05-28
 * @author：Vic Ly
 */
@RestController
@RequestMapping("/goodsInfo")
public class GoodsInfoController extends BaseController {
	@Resource
	private GoodsInfoService goodsInfoService;

	/**
	 * 分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(GoodsInfoQuery query) {
		return getSuccessResponseVO(goodsInfoService.findListByPage(query));
	}
	/**
	 * 新增
	 */
	@PostMapping("/add")
	public ResponseVO add(GoodsInfo bean) {
		this.goodsInfoService.add(bean);
		return getSuccessResponseVO();
	}
	/**
	 * 批量新增
	 */
	@PostMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<GoodsInfo> listBean) {
		this.goodsInfoService.addBatch(listBean);
		return getSuccessResponseVO();
	}
	/**
	 * 批量新增或修改
	 */
	@PutMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<GoodsInfo> listBean) {
		this.goodsInfoService.addOrUpdateBatch(listBean);
		return getSuccessResponseVO();
	}
	/**
	 * 根据Id查询
	 */
	@GetMapping("/getIdBy")
	public ResponseVO getGoodsInfoById(Integer id) {
		return getSuccessResponseVO(this.goodsInfoService.getById(id));
	}
	/**
	 * 根据Id更新
	 */
	@PostMapping("/UpdateIdBy")
	public ResponseVO updateGoodsInfoById(GoodsInfo bean, Integer id) {
		this.goodsInfoService.updateById(bean,id);
		return getSuccessResponseVO();
	}
	/**
	 * 根据Id删除
	 */
	@DeleteMapping("/deleteIdBy")
	public ResponseVO deleteGoodsInfoById(Integer id) {
		this.goodsInfoService.deleteById(id);
		return getSuccessResponseVO();
	}
	/**
	 * 根据GoodsCode查询
	 */
	@GetMapping("/getGoodsCodeBy")
	public ResponseVO getGoodsInfoByGoodsCode(String goodsCode) {
		return getSuccessResponseVO(this.goodsInfoService.getByGoodsCode(goodsCode));
	}
	/**
	 * 根据GoodsCode更新
	 */
	@PostMapping("/UpdateGoodsCodeBy")
	public ResponseVO updateGoodsInfoByGoodsCode(GoodsInfo bean, String goodsCode) {
		this.goodsInfoService.updateByGoodsCode(bean,goodsCode);
		return getSuccessResponseVO();
	}
	/**
	 * 根据GoodsCode删除
	 */
	@DeleteMapping("/deleteGoodsCodeBy")
	public ResponseVO deleteGoodsInfoByGoodsCode(String goodsCode) {
		this.goodsInfoService.deleteByGoodsCode(goodsCode);
		return getSuccessResponseVO();
	}
	/**
	 * 根据GoodsStock查询
	 */
	@GetMapping("/getGoodsStockBy")
	public ResponseVO getGoodsInfoByGoodsStock(Integer goodsStock) {
		return getSuccessResponseVO(this.goodsInfoService.getByGoodsStock(goodsStock));
	}
	/**
	 * 根据GoodsStock更新
	 */
	@PostMapping("/UpdateGoodsStockBy")
	public ResponseVO updateGoodsInfoByGoodsStock(GoodsInfo bean, Integer goodsStock) {
		this.goodsInfoService.updateByGoodsStock(bean,goodsStock);
		return getSuccessResponseVO();
	}
	/**
	 * 根据GoodsStock删除
	 */
	@DeleteMapping("/deleteGoodsStockBy")
	public ResponseVO deleteGoodsInfoByGoodsStock(Integer goodsStock) {
		this.goodsInfoService.deleteByGoodsStock(goodsStock);
		return getSuccessResponseVO();
	}
}